
/**
 * primitive Billboard 大量加载
 * 
 */
import Primitive from "../Primitive"

const DEFAULT_STYLE = {
  eyeOffset: new Cesium.Cartesian3(0.0, 0.0, 0.0),
  scaleByDistance: new Cesium.NearFarScalar(1.5e2, 2.0, 1.5e7, 0.5),
  scale: 1.0, // default: 1.0
  color : Cesium.Color.SKYBLUE,
  width: 30,
  height: 30,
  alignedAxis : Cesium.Cartesian3.UNIT_Y
}

export default class BillboardPrimitive extends Primitive {
  /**
   * 
   * @param {*} positions 
   * @param {*} imageUrl 
   * @param {*} options 
   */
  constructor(positions, imageUrl , options = {}) {
    super()
    this._positions = positions
    this._imageUrl = imageUrl
    this._type = 'billboard_primitive'
    this._style = {
      ...DEFAULT_STYLE,
      ...options
    }
    
    this.delegate = {}

    this.mounted()
  }

  /**
   * 属性初始化
   */
  mounted() {
    this.positions = this._positions
    this.imageUrl = this._imageUrl
    this.style = this._style
  }

  /**
   * 
   * @param {*} style 
   * @returns 
   */

  setStyle(style) {
    if (!style) return
    Object.assign(this._style, { ...style })
    Object.assign(this.delegate, {
      ...this._style
    })
  }

  get positions() {
    return this._positions
  }

  set positions(val) {
    this._positions = val
    this.delegate.position = this._positions
  }

  get imageUrl(){
    return this._imageUrl
  }

  set imageUrl(val){
    this._imageUrl = val
    this.delegate.image = this._imageUrl
   
  }
}
